package cn.stylefeng.guns.sys.modular.system.controller;

import cn.stylefeng.guns.base.pojo.node.LayuiTreeNode;
import cn.stylefeng.guns.base.pojo.node.ZTreeNode;
import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
import cn.stylefeng.guns.sys.modular.system.entity.BtyPinpai;
import cn.stylefeng.guns.sys.modular.system.factory.LayuiTreeFactory;
import cn.stylefeng.guns.sys.modular.system.mapper.BtyPinpaiMapper;
import cn.stylefeng.guns.sys.modular.system.model.params.ZxHuopinParam;
import cn.stylefeng.guns.sys.modular.system.model.params.BtyPinpaiParam;
import cn.stylefeng.guns.sys.modular.system.model.result.ZxHuopinResult;
import cn.stylefeng.guns.sys.modular.system.model.result.BtyPinpaiResult;
import cn.stylefeng.guns.sys.modular.system.service.ZxHuopinService;
import cn.stylefeng.guns.sys.modular.system.service.BtyPinpaiService;
import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.core.reqres.response.ResponseData;
import cn.stylefeng.roses.core.treebuild.DefaultTreeBuildFactory;
import cn.stylefeng.roses.core.util.ToolUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;


/**
 * 装修科目表控制器
 *
 * @author gyz
 * @Date 2020-11-02 13:43:19
 */
@Controller
@RequestMapping("/pinpai")
public class BtyPinpaiController extends BaseController {

    private String PREFIX = "/modular/system/pinpai";

    @Autowired
    private BtyPinpaiService btyPinpaiService;

    @Autowired
    private BtyPinpaiMapper btyPinpaiMapper;
    /**
     * 跳转到主页面
     *
     * @author gyz
     * @Date 2020-11-02
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "/btyPinpai.html";
    }

    /**
     * 新增页面
     *
     * @author gyz
     * @Date 2020-11-02
     */
    @RequestMapping("/add")
    public String add() {
        return PREFIX + "/btyPinpai_add.html";
    }

    /**
     * 编辑页面
     *
     * @author gyz
     * @Date 2020-11-02
     */
    @RequestMapping("/edit")
    public String edit() {
        return PREFIX + "/btyPinpai_edit.html";
    }

    /**
     * 新增接口
     *
     * @author gyz
     * @Date 2020-11-02
     */
    @RequestMapping("/addItem")
    @ResponseBody
    public ResponseData addItem(BtyPinpaiParam btyPinpaiParam) {

        this.btyPinpaiService.add(btyPinpaiParam);
        return ResponseData.success();
    }

    /**
     * 编辑接口
     *
     * @author gyz
     * @Date 2020-11-02
     */
    @RequestMapping("/editItem")
    @ResponseBody
    public ResponseData editItem(BtyPinpaiParam btyPinpaiParam) {
        this.btyPinpaiService.update(btyPinpaiParam);
        return ResponseData.success();
    }

    /**
     * 删除接口
     *
     * @author gyz
     * @Date 2020-11-02
     */
    @RequestMapping("/delete")
    @ResponseBody
    public ResponseData delete(BtyPinpaiParam BtyPinpaiParam) {
        this.btyPinpaiService.delete(BtyPinpaiParam);
        return ResponseData.success();
    }

    /**
     * 查看详情接口
     *
     * @author gyz
     * @Date 2020-11-02
     */
    @RequestMapping("/detail")
    @ResponseBody
    public ResponseData detail(BtyPinpaiParam BtyPinpaiParam) {
        //父级科目名称
        BtyPinpai detail = this.btyPinpaiService.getDetailById(BtyPinpaiParam.getId());
        return ResponseData.success(detail);
    }

    /**
     * 查询列表
     *
     * @author gyz
     * @Date 2020-11-02
     */
    @ResponseBody
    @RequestMapping("/list")
    public LayuiPageInfo list(BtyPinpaiParam BtyPinpaiParam) {
        return this.btyPinpaiService.findPageBySpec(BtyPinpaiParam);
    }


    @ResponseBody
    @RequestMapping("/queryPinpai")
    public ResponseData queryPinpai(BtyPinpaiParam projectParam) {
        List<Map<String, Object>> maps = btyPinpaiMapper.customMapList(projectParam);
        return ResponseData.success(maps);
    }

}


